﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once
#include "GcmpGuiMainFrameInterface.h"
#include "OwnerPtr.h"
#include "WeakReferenceable.h"

namespace gcmp
{
    class IControl;
    class ICommandButtonDefinition;
    class ILineEditDefinition;
    class IComboBoxDefinition;
    class IRibbonToolBarHandler;

    /// \brief Ribbontoolbar接口
    FINAL_INTERFACE class GCMP_GUI_MAIN_FRAME_INTERFACE_EXPORT IRibbonToolBarControl : public WeakReferenceable
    {
    public:
        /// \brief 析构函数
        virtual ~IRibbonToolBarControl();

        /// \brief 创建Ribbontoolbar对象
        ///
        /// \param toolBarControlId       Ribbontoolbar的Id,设置的唯一标识
        /// \return 创建出Ribbontoolbar对象，失败时返回空指针
        static OwnerPtr<IRibbonToolBarControl> Create(const std::wstring& toolBarControlId);

        /// \brief 添加button到RibbonToolBar,按控件添加顺序排列
        ///
        /// \param pButtonDefinition    ICommandButtonDefinition对象
        /// \return IControl对象，添加时会判断pButtonDefinition是否添加过，添加过会失败，失败时返回空指针
        virtual IControl* AddButton(OwnerPtr<ICommandButtonDefinition> pButtonDefinition) = 0;

        /// \brief 添加lineEdit到RibbonToolBar,按控件添加顺序排列
        ///
        /// \param pLineEditDefinition    ILineEditDefinition对象
        /// \return  IControl对象，添加时会判断pLineEditDefinition是否添加过，添加过会失败,失败时返回空指针
        virtual IControl* AddLineEdit(OwnerPtr<ILineEditDefinition> pLineEditDefinition) = 0;

        /// \brief 添加comboBox到RibbonToolBar,按控件添加顺序排列
        ///
        /// \param pComboBoxDefinition    IComboBoxDefinition对象
        /// \return  IControl对象，添加时会判断pComboBoxDefinition是否添加过，添加过会失败,失败时返回空指针
        virtual IControl* AddComboBox(OwnerPtr<IComboBoxDefinition> pComboBoxDefinition) = 0;

        /// \brief 添加分隔栏，若超过两个控件，会自动换行，将控件双行显示
        ///
        /// \return  添加成功返回true
        virtual bool AddSeparator() = 0;

        /// \brief 设置RibbonToolBar的可见状态，用户可通过派生IRibbonToolBarHandler定制个性化的RibbonToolBar可见状态
        ///
        /// \param  opToolBarHandler RibbonToolBar控制对象
        /// \return  true表示成功，false表示失败
        virtual bool SetToolBarHandler(OwnerPtr<IRibbonToolBarHandler> opToolBarHandler) = 0;

        /// \brief 得到Ribbontoolbar的可见性
        ///
        /// Ribbontoolbar的状态由opToolBarHandler控制，其返回不可见时，Ribbontoolbar不可见，而其返回可见时，Ribbontoolbar下所有子控件都不可见时，Ribbontoolbar也不可见，否则可见
        /// \return  返回true表示可见，返回false表示不可见
        virtual bool IsVisible() const = 0;

        /// \brief 得到该Ribbontoolbar上所有控件
        ///
        /// \return  控件集合
        virtual std::vector<IControl*> GetAllControls() const = 0;
    };
}